home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / TC Prog Guide.cpt / picture ƒ / anringpi.c < prev    next >
C/C++ Source or Header  |  1991-02-26  |  3KB  |  136 lines

  1. /*
  2. *    FILE:        anringpi.c
  3. *    AUTHOR:        R. Gonzalez
  4. *    CREATED:    November 8, 1990
  5. *
  6. *    Sample animated pict application.  Includes main() function.
  7. *
  8. *    ASSOCIATED FILES:
  9. *        anringpi.h,class.c,class.h,screen.c,screen.h,,coord.c,coord.h,
  10. *        frame.c,frame.h,color.h,error.c,error.h,trans.c,trans.h,oops.h,
  11. *        camera.c,camera.h,project.c,project.h,segment.c,segment.h,
  12. *        line.c,line.h,cube.c,cube.h,anring.c,anring.h,backdrop.c,
  13. *        backdrop.h,pict.c,pict.h,animate.h,animate.c,atring.c,atring.h,
  14. *        several ANSI and system-specific headers (used in screen.c
  15. *        and class.c).
  16. *
  17. *    PROJECT CONTENTS (Think C):
  18. *        above-listed source (.c) files, MacTraps, ANSI or ANSI-881,
  19. *        oops library.
  20. *
  21. *    COMPILATION (Think C):
  22. *        68881 code generation if ANSI-881 is used.
  23. */
  24.  
  25. # include    "anringpi.h"
  26. # include    "anring.h"
  27. # define    NUM_ITERATIONS    100
  28.  
  29. /******************************************************************
  30. *    initialize
  31. ******************************************************************/
  32. boolean    An_Ring_Pict::init(void)
  33. {
  34.     Translation        *transl;
  35.     
  36.     Generic_Pict::init();
  37.     
  38.     projector1 = new(Projector);
  39.     projector1->init();
  40.     projector1->set_background_color(RED);
  41.     projector1->set_cropping_frame(0.,-.05,1.,.5);
  42.     projector1->set_projection_frame(0.,0.,1.8,.9);
  43.  
  44.     projector2 = new(Corner_Projector);
  45.     projector2->init();
  46.     
  47.     projector1->set_screen(screen);
  48.     projector2->set_screen(screen);
  49.     
  50.     camera1 = new(Camera);
  51.     camera1->init();
  52.     camera1->set_position(0.,3.,0.,0.,.29,0.);
  53.     camera2 = new(Camera);
  54.     camera2->init();
  55.     camera2->set_position(0.,100.,10.,0.,PI/2.,0.);
  56.     camera2->set_focal_length(20.);
  57.     
  58.     transl = new(Translation);
  59.     transl->init();
  60.     transl->set(0.,0.,10.);
  61.     
  62.     segment = new(Animated_Ring);
  63.     segment->init();
  64.     segment->move(transl);
  65.     
  66.     transl->destroy();
  67.     delete(transl);
  68.     
  69.     return TRUE;
  70. }
  71.  
  72. /******************************************************************
  73. *    run
  74. ******************************************************************/
  75. void    An_Ring_Pict::run(void)
  76. {
  77.     int        i;
  78.     Transformation    *identity;
  79.     
  80.     identity = new(Transformation);
  81.     identity->init();
  82.     
  83.     for (i=0 ; i<NUM_ITERATIONS && !screen->mouse_button_is_down() ; i++)
  84.     {
  85.         projector1->clear();
  86.         segment->set_color(YELLOW);
  87.         segment->draw(camera1,projector1,identity);
  88.         projector2->clear();
  89.         segment->set_color(BLUE);
  90.         segment->draw(camera2,projector2,identity);
  91.         segment->animate();
  92.     }
  93.     
  94.     screen->wait();
  95.     
  96.     identity->destroy();
  97.     delete(identity);
  98. }
  99.  
  100. /******************************************************************
  101. *    destroy
  102. ******************************************************************/
  103. boolean    An_Ring_Pict::destroy(void)
  104. {
  105.     projector1->destroy();
  106.     delete(projector1);
  107.     projector2->destroy();
  108.     delete(projector2);
  109.  
  110.     camera1->destroy();
  111.     delete(camera1);
  112.     camera2->destroy();
  113.     delete(camera2);
  114.     
  115.     segment->destroy();
  116.     delete(segment);
  117.  
  118.     return Generic_Pict::destroy();
  119. }
  120.  
  121. /******************************************************************
  122. *    main function
  123. ******************************************************************/
  124. main()
  125. {
  126.     Generic_Pict    *pict;
  127.     
  128.     pict = new(An_Ring_Pict);
  129.     pict->init();
  130.     pict->run();
  131.     pict->destroy();
  132.     delete(pict);
  133. }
  134.  
  135.     
  136.